Repository navigation
修复动态卸载后的类型缓存残留和悬空引用 - #143
Open
BitmapLong wants to merge 2 commits into
Open
BitmapLong wants to merge 2 commits into
BitmapLong wants to merge 2 commits into
Conversation
增加宿主程序接口断言、Interface Switch 缓存符号注册;记录 Runtime typemap 地址。
Implement logic to remove module typemap from pinned maps.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这次主要修复了 Go 1.23.2 下动态卸载模块时的两个问题:
removeModuleToTypelinks()没有实际清理逻辑,模块卸载后,Runtime 的pinnedTypemaps仍然保留相关引用,导致多次加载、卸载后内存持续增长。现在会在卸载时清理对应的类型映射。typeAssert和interfaceSwitch相关符号的注册,避免旧模块卸载后,接口断言和类型切换缓存继续引用已释放的类型信息。在 Go 1.23.2 / Linux AMD64 环境下进行了验证,包括连续 3000 次加载与卸载、同包路径下结构体布局变化、并发调用及 GC 测试,修复后未再复现此前的问题。
由于涉及 Go Runtime 内部结构,目前仅针对已测试环境做了兼容性限制,其他 Go 版本和平台仍需单独验证。